All Questions
203 questions
0votes
1answer
115views
Find all files in directory and apply commands to each of them
I want to apply commands below to all files in a directory instead of one file. cat file.txt | sed -E "s/\@([0-9]+)\W+~(.*?)/\1 \2/g" | tr -d '~' cat file.txt | sed -E "s/\@([0-9]+).*\~...
0votes
1answer
58views
Replacing variable correctly in alias function
I'm trying to create an alias function to remove inputted line from file: function remove_line(){ line_to_remove="'s/^"$1"$//g'" sed -i $(line_to_remove) my_file } ...
-1votes
2answers
562views
Use find, cat, etc... to generate an M3U playlist from album playlists
I have a music folder with selected playlists in each folder titled "playlist.m3u" (should also match *.m3u8). What I would like to do is have a shell script generate a playlist concatenated ...
2votes
2answers
516views
Update any date to the current date in a text file
I have a text file which contains several occurrences of dates. All the dates are written in the format Mon-DD-YYYY. I have to update all these dates in the current date keeping the format Mon-DD-YYYY....
2votes
2answers
159views
Unpivoting Delimited String to get the parent child relationship
I have a scenario where in need to unpivot the data to achieve the parent child relationship. My source data is as below: Key_Col|Hierarchy 1|a,b,c,d 2|a,b,c,d,e My Expected Output below: Key Col ...
3votes
1answer
551views
How to get the result of smbstatus into a shell script variable
Running smbstatus on the command line I get the following: ❯ smbstatus Samba version 4.17.3 PID Username Group Machine Protocol Version Encryption ...
1vote
0answers
464views
how do i put a $variable inside {curly..brackets} in a bash loop? [duplicate]
i'm writing a text art script where i take some input and repeat it, textbook simple. echo "a script that takes some input and repeats it 100 times" read -e -p "text input " ...
2votes
2answers
54views
get delimiter index and convert EPOCH time
I need to search time in the first line and get the position index and then convert other lines' EPOCH time to human readable time. The EPOCH time position is random but it has a header. Sample as ...
1vote
3answers
108views
get specific output in linux after string
Controller loading lists... ------------------------------------------------- command: select SERVICE_NAME from <table_name> ------------------------------------------------- ...
0votes
1answer
147views
Permutation with bash - Spread Five over Eight
Assuming I have the values A B C D E and eight places 1 2 3 4 5 6 7 8. How can I get all possible combinations printed with two- and three-time repetitions? Example: 1 2 3 4 5 6 7 8 _______________ A ...
0votes
1answer
76views
Perform text-processing task on remote server using shell variable specified on local machine
I'm trying to write a shell script that proceses user information on a remote server via SSH. The user to be processed will be read interactively by the script. My current attempt looks like this #!/...
0votes
1answer
5kviews
add a new line after a specific string in a file? [duplicate]
Right now I'm using echo sed '/\Random/a \ newly added line' info.txt to append some text to a file but I also need to add text below a certain string let's say random, I know it is possible with ...
0votes
1answer
2kviews
RegEx to extract file paths from a logfile
I need to get the file paths from a log file. I thought I will try this with regex. A file path would look like this: 75/751234/751234V0001_test-tag1-tag02-75x75_01.jpg I'm not a pro in Regex, so I ...
0votes
4answers
479views
Merge 2 CSV file to create one CSV file with one more column of difference
I have 2 CSV files. Let's call them 1.csv and 2.csv The first one (1.csv) looks as follows: 1,3543 23,3632 12,7665 1,9795 32,8793 35,0290 The second file (2.txt) looks as follows: 1,4543 3,3223 4,...
0votes
2answers
651views
How to match multiple keywords in a log file that occur on the same line using bash script
I created an array with keywords to match in a log file and display the matching lines on standard output. If a line contains more than one keyword, I want the output to highlight all the keywords ...